package com.taotao.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.EUDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbItem;
import com.taotao.service.ItemService;

@RequestMapping("/item/")
@Controller
public class ItemController {
	@Autowired
	private ItemService itemService;
	
	@RequestMapping("{itemId}")
	@ResponseBody
	TbItem getItemById(@PathVariable long itemId) {
		TbItem item=itemService.getItemById(itemId);
		return item;
	}
	
	@RequestMapping("list")
	@ResponseBody
	EUDataGridResult getItemList(Integer page,Integer rows) {
		EUDataGridResult itemList = itemService.getItemList(page, rows);
		return itemList;
	}
	
	@RequestMapping("save")
	@ResponseBody
	TaotaoResult saveItem(TbItem tbItem,String desc,String itemParams) {
		TaotaoResult taotaoResult = null;
		try {
			taotaoResult = itemService.createItem(tbItem,desc,itemParams);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return taotaoResult;
		
	}
	
	
}
